/**
 *
 */
package com.naiterui.ehp.bs.im.remote;

import com.naiterui.ehp.bp.support.exception.BusinessException;
import com.naiterui.ehp.bp.support.exception.ResponseVO;
import com.naiterui.ehp.bp.support.security.SettingConfig;
import com.naiterui.ehp.bp.utils.net.RestHttpUtil;
import com.naiterui.ehp.bs.im.config.RemoterConfig;
import java.util.HashMap;
import java.util.Map;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.stereotype.Service;

/**
 * @author guoyongxiang
 * @since 2.9.0
 */
@Service
@RequiredArgsConstructor
public class ImWeixinRemoter implements IImWeixinRemoter {

    @Autowired
    private RemoterConfig remoterConfig;

    @Override
    public Long checkMiniToken(String token) throws BusinessException {
        Map map = new HashMap();
        map.put(SettingConfig.TOKEN_HEADER, token);
        return RestHttpUtil.post()
                .url(remoterConfig.getMiniappCheckToken())
                .header(map)
                .executeData(new ParameterizedTypeReference<ResponseVO<Long>>() {
                });
    }

}
